import http from '@utils/request'

// 请求科目列表中的表格数据
export const subjectPage = (params:ISubjectList):Promise<IsubjectPageData>=>{
    return http.get<IsubjectPageData>('/crm/teach/subject/page',{params})
} 

// 请求科目列表中的表格数据
export const gradeAll = (data:{subjectId:string}):Promise<IGradeAll>=>{
    return http.get<IGradeAll>('/crm/teach/grade/all', data)
}

// 添加科目
export const subjectAdd = (data:addData):Promise<IsubjectAdd>=>{
    return http.post<IsubjectAdd>('/crm/teach/subject/add', data)
} 

interface addData {
    subjectName:string;
    enabled:string
}

// 请求科目列表中的表格数据类型
export interface ISubjectList{
    current:number;
    size:number;
    subjectName?:string;
    enabled?:string;
}

export interface IsubjectPage {
    id:string;
    subjectName:string;
    enabled: "0" | "1";
    createBy:string;
    createTime:number;
    updateBy: string | null;
    updateTime: number | null;
}

interface IsubjectPageData {
    code:string;
    msg:string;
    data:{
        records:IsubjectPage[];
        total: number;
        size: number;
        current: number;
        orders: any[]; // 由于 orders 是一个数组，不确定具体元素类型，暂时使用 any[]
        optimizeCountSql: boolean;
        searchCount: boolean;
        countId: any;
        maxLimit: any;
        pages: number;
    }
}

// 查询科目等级
export interface Igradelist{
    current:number;
    size:number;
    subjectName?:string;
    GradeName?:string;
}

export interface IGradeData {
    id: string;
    subjectId: string;
    gradeName: string;
    amount: number;
    protocol: string;
    enabled: number;
    delFlag: number;
    createBy: string;
    createTime: number;
    updateBy: string | null;
    updateTime: number | null;
}

// interface IGradeData {
//     records: IGrade[];
//     total: number;
//     size: number;
//     current: number;
//     orders: any[];
//     optimizeCountSql: boolean;
//     searchCount: boolean;
//     countId: any;
//     maxLimit: any;
//     pages: number;
// }

interface IGradeAll {
    code: string;
    msg: string;
    data: IGradeData;
}

interface IsubjectAdd{
    code:string;
    msg:string;
    data:IsubjectPage|null
}